package com.csi.controller.user;

import com.alibaba.fastjson2.JSON;
import com.csi.domain.AccountCredDetails;
import com.csi.domain.BindAccount;
import com.csi.pojo.Result;
import com.csi.service.UserService;
import com.csi.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 查询用户指定的信用卡信息
 */
@WebServlet("/user/queryAccountCredDetailsController")
public class QueryAccountCredDetailsController extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=utf-8");

        PrintWriter out = resp.getWriter();

        String userNumber = req.getParameter("userNumber");
        String accountNumber = req.getParameter("accountNumber");

        UserService userService = new UserServiceImpl();

        AccountCredDetails accountCredDetails = userService.queryAccountCredDetails(userNumber, accountNumber);

        Result<AccountCredDetails> result = new Result<>();
        result.setCode(200);
        result.setMsg("success");
        result.setDatas(accountCredDetails);

        out.print(JSON.toJSONString(result));

        out.flush();
        out.close();
    }
}
